package com.designPattern.clone;

/**
 * 【原型模式】
 * 【实现方法】
 * 需要克隆的方法需要实现Cloneable接口
 * 然后实现clone()方法完成克隆
 * @author mxs
 */
public class Sheep implements Cloneable{
    String name;
    int id;

    public Sheep(String name, int id) {
        this.name = name;
        this.id = id;
    }

    @Override
    public String toString() {
        return "Sheep{" +
                "name='" + name + '\'' +
                ", id=" + id +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Sheep sheep = null;
        sheep = (Sheep) super.clone();
        return sheep;
    }
}
